home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume14 / pcomm / part02 < prev    next >
Encoding:
Internet Message Format  |  1988-05-17  |  53.2 KB

  1. Subject:  v14i100:  Dial out and terminal emulator, Part02/06
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: fthood!egray@uunet.UU.NET
  7. Posting-number: Volume 14, Issue 100
  8. Archive-name: pcomm/part02
  9.  
  10. #! /bin/sh
  11. # This is a shell archive, meaning:
  12. # 1. Remove everything above the #! /bin/sh line.
  13. # 2. Save the resulting text in a file.
  14. # 3. Execute the file with /bin/sh (not csh) to create:
  15. #    Makefile
  16. #    Unixpc.shar
  17. #    dial_dir.h
  18. #    misc.h
  19. #    modem.h
  20. #    param.h
  21. #    status.h
  22. #    xmodem.h
  23. #    admin.c
  24. #    chg_dir.c
  25. #    curses.c
  26. #    d_delete.c
  27. #    d_lib.c
  28. #    d_manual.c
  29. #    d_menu.c
  30. export PATH; PATH=/bin:/usr/bin:$PATH
  31. echo shar: "extracting 'Makefile'" '(3099 characters)'
  32. if test -f 'Makefile'
  33. then
  34.     echo shar: "will not over-write existing file 'Makefile'"
  35. else
  36. sed 's/^X//' << \SHAR_EOF > 'Makefile'
  37. X#                PCOMM
  38. X#            for a generic Unix box
  39. X#
  40. X# valid compile time definitions (CFLAGS) are:
  41. X#
  42. X# OLDCURSES    use termcap (in lieu of terminfo) for curses
  43. X# UNIXPC    use AT&T Unix PC 7300/3b1 specific routines
  44. X# SGID        retore the real group id before doing anything dangerous
  45. X#
  46. X# for systems without getcwd(3) or getopt(3)
  47. X#
  48. X#GETCWD = getcwd.o
  49. X#GETOPT = getopt.o
  50. X
  51. XCC = cc -O
  52. XCFLAGS =
  53. X#CURSES = -lcurses -ltermlib
  54. XCURSES = -lcurses
  55. XLDFLAGS =
  56. XSHAR = shar -a
  57. X
  58. XOBJECTS = $(GETCWD) $(GETOPT) admin.o chg_dir.o curses.o d_delete.o d_lib.o \
  59. X    d_manual.o d_menu.o d_print.o d_prompt.o d_revise.o data_log.o \
  60. X    di_delay.o di_win.o dial.o expand.o help.o info.o init.o input.o \
  61. X    line_set.o list_dir.o ls_menu.o m_lib.o main.o n_shell.o p_lib.o \
  62. X    pexit.o port.o redial.o s_axfer.o s_gen.o s_menu.o s_modem.o \
  63. X    s_prompt.o s_term.o s_tty.o screen.o st_line.o strings.o terminal.o \
  64. X    x_ascii.o x_batch.o x_menu.o x_rcv.o x_send.o x_win.o xmodem.o
  65. X
  66. Xpcomm:    $(OBJECTS)
  67. X    $(CC) $(LDFLAGS) $(OBJECTS) -o pcomm $(CURSES)
  68. X
  69. Xlint:
  70. X    lint $(CFLAGS) *.c
  71. X
  72. Xshar:
  73. X    $(SHAR) Readme Release.notes Doc Pcomm.1 Pcomm.dial_dir Pcomm.modem \
  74. X    Pcomm.param > pcomm_sh.1
  75. X    $(SHAR) Makefile dial_dir.h misc.h modem.h param.h status.h xmodem.h \
  76. X    admin.c chg_dir.c curses.c d_delete.c d_lib.c d_manual.c d_menu.c \
  77. X    d_print.c > pcomm_sh.2
  78. X    $(SHAR) d_prompt.c d_revise.c data_log.c di_delay.c di_win.c dial.c \
  79. X    expand.c getcwd.c getopt.c help.c info.c init.c input.c > pcomm_sh.3
  80. X    $(SHAR) line_set.c list_dir.c ls_menu.c m_lib.c main.c n_shell.c \
  81. X    p_lib.c pexit.c port.c redial.c s_axfer.c s_gen.c > pcomm_sh.4
  82. X    $(SHAR) s_menu.c s_modem.c s_prompt.c s_term.c s_tty.c screen.c \
  83. X    st_line.c strings.c terminal.c x_ascii.c x_batch.c > pcomm_sh.5
  84. X    $(SHAR) x_menu.c x_rcv.c x_send.c x_win.c xmodem.c > pcomm_sh.6
  85. X
  86. Xadmin.o:    dial_dir.h param.h
  87. Xchg_dir.o:    misc.h
  88. Xcurses.o:    misc.h
  89. Xd_delete.o:    dial_dir.h misc.h param.h
  90. Xd_lib.o:    dial_dir.h param.h status.h
  91. Xd_manual.o:    dial_dir.h
  92. Xd_menu.o:    dial_dir.h misc.h param.h
  93. Xd_print.o:    dial_dir.h misc.h
  94. Xd_prompt.o:    dial_dir.h misc.h
  95. Xd_revise.o:    dial_dir.h misc.h param.h
  96. Xdata_log.o:    misc.h param.h status.h
  97. Xdi_delay.o:    misc.h param.h
  98. Xdi_win.o:    dial_dir.h misc.h modem.h param.h status.h
  99. Xdial.o:        dial_dir.h modem.h param.h status.h
  100. Xhelp.o:        misc.h
  101. Xinit.o:        misc.h status.h
  102. Xline_set.o:    dial_dir.h param.h status.h
  103. Xlist_dir.o:    misc.h
  104. Xls_menu.o:    dial_dir.h misc.h param.h
  105. Xm_lib.o:    modem.h status.h
  106. Xmain.o:        dial_dir.h modem.h param.h status.h
  107. Xp_lib.o:    param.h status.h
  108. Xpexit.o:    dial_dir.h misc.h param.h status.h
  109. Xport.o:        dial_dir.h modem.h status.h
  110. Xredial.o:    dial_dir.h misc.h
  111. Xs_axfer.o:    misc.h param.h
  112. Xs_gen.o:    misc.h param.h
  113. Xs_menu.o:    misc.h
  114. Xs_modem.o:    misc.h modem.h
  115. Xs_prompt.o:    misc.h
  116. Xs_term.o:    misc.h param.h
  117. Xs_tty.o:    misc.h modem.h status.h
  118. Xscreen.o:    param.h status.h
  119. Xst_line.o:    dial_dir.h misc.h modem.h param.h status.h
  120. Xterminal.o:    dial_dir.h modem.h param.h status.h
  121. Xx_ascii.o:    param.h status.h
  122. Xx_batch.o:    misc.h xmodem.h
  123. Xx_menu.o:    misc.h xmodem.h
  124. Xx_rcv.o:    dial_dir.h misc.h xmodem.h
  125. Xx_send.o:    dial_dir.h misc.h status.h xmodem.h
  126. Xx_win.o:    dial_dir.h misc.h status.h xmodem.h
  127. Xxmodem.o:    param.h status.h xmodem.h
  128. SHAR_EOF
  129. if test 3099 -ne "`wc -c < 'Makefile'`"
  130. then
  131.     echo shar: "error transmitting 'Makefile'" '(should have been 3099 characters)'
  132. fi
  133. fi
  134. echo shar: "extracting 'Unixpc.shar'" '(8328 characters)'
  135. if test -f 'Unixpc.shar'
  136. then
  137.     echo shar: "will not over-write existing file 'Unixpc.shar'"
  138. else
  139. sed 's/^X//' << \SHAR_EOF > 'Unixpc.shar'
  140. X#! /bin/sh
  141. X# This is a shell archive, meaning:
  142. X# 1. Remove everything above the #! /bin/sh line.
  143. X# 2. Save the resulting text in a file.
  144. X# 3. Execute the file with /bin/sh (not csh) to create:
  145. X#    Dial_codes
  146. X#    Ifile.sh
  147. X#    Makefile
  148. X#    Pcomm.modem
  149. X# This archive created: Sun Mar 27 10:35:36 1988
  150. Xexport PATH; PATH=/bin:/usr/bin:$PATH
  151. Xecho shar: "extracting 'Dial_codes'" '(2193 characters)'
  152. Xif test -f 'Dial_codes'
  153. Xthen
  154. X    echo shar: "will not over-write existing file 'Dial_codes'"
  155. Xelse
  156. Xsed 's/^X//' << \SHAR_EOF > 'Dial_codes'
  157. XX                  PCOMM v1.0
  158. XX
  159. XX                  AT&T Unix PC 7300
  160. XX                Dialing Codes
  161. XX
  162. XX    The dialing codes used by the OBM (On Board Modem) are not straight-
  163. XX    forward.  The modem setup, as distributed, looks like this:
  164. XX
  165. XX    -------------------------- Modem Setup --------------------------
  166. XX
  167. XX        1) Modem name ............. OBM
  168. XX
  169. XX        2) Modem init string ......
  170. XX        3) Dialing command ........ %
  171. XX        4) Dialing cmd suffix ..... @
  172. XX        5) Hangup string ..........
  173. XX        6) 300 baud connect ....... CONNECT
  174. XX        7) 1200 baud connect ...... CONNECT
  175. XX        8) 2400 baud connect ......
  176. XX        9) 4800 baud connect ......
  177. XX        10) 9600 baud connect .....
  178. XX        11) 19200 baud connect ....
  179. XX        12) No connect string 1 ...
  180. XX        13) No connect string 2 ...
  181. XX        14) No connect string 3 ...
  182. XX        15) No connect string 4 ...
  183. XX
  184. XX    ---------------------------------------------------------------
  185. XX    OPTION ==> _                    Press ESC to return
  186. XX
  187. XX    The relevant fields of the modem setup are:
  188. XX
  189. XX        1) Modem name.  This must be "OBM".
  190. XX
  191. XX    NOTE: Pcomm uses the modem name as a flag to determine which dialing
  192. XX    method to use.  The string "OBM" is a "reserved word" that pcomm uses
  193. XX    to switch to the AT&T 7300 Unix PC dialing method.
  194. XX
  195. XX        3) Dialing command.  This should be '%' for touch tone
  196. XX        dialing or '^' for pulse dialing. 
  197. XX
  198. XX        4) Dialing cmd suffix.  This must be the '@' character.
  199. XX
  200. XX        6-7) Connect strings.  The 300 and 1200 baud connect
  201. XX        strings must both be set to "CONNECT".
  202. XX
  203. XX    NOTE: The OBM cannot determine the connected baud rate if it's 
  204. XX    different from what it expects.  The two identical connect strings
  205. XX    disable this feature.
  206. XX
  207. XX
  208. XX    Additional OBM dialing commands from phone(7):
  209. XX
  210. XX        '~'    wait for next dial tone
  211. XX        ','    pause 2 seconds
  212. XX        ':'    pause 10 seconds
  213. XX        '&'    perform a hookflash
  214. XX        '%'    begin tone dialing
  215. XX        '^'    begin pulse dialing
  216. XX
  217. XX    These commands can be inserted into the phone number string, for
  218. XX    example:
  219. XX        
  220. XX        555-1234~56    dial 555-1234, wait for dial tone, dial 56
  221. XX        9,555-1234    dial 9, wait 2 seconds, dial 555-1234
  222. XX        %555^1234    dial 555 using tone, dial 1234 using pulse
  223. XX
  224. XX    NOTE: The dialing commands for the OBM are not subject to character
  225. XX    synonym translations, therefore the '^' and '~' characters do NOT
  226. XX    have to be preceded by the '\' character to remove their special
  227. XX    meaning.
  228. XSHAR_EOF
  229. Xif test 2193 -ne "`wc -c < 'Dial_codes'`"
  230. Xthen
  231. X    echo shar: "error transmitting 'Dial_codes'" '(should have been 2193 characters)'
  232. Xfi
  233. Xfi
  234. Xecho shar: "extracting 'Ifile.sh'" '(705 characters)'
  235. Xif test -f 'Ifile.sh'
  236. Xthen
  237. X    echo shar: "will not over-write existing file 'Ifile.sh'"
  238. Xelse
  239. Xsed 's/^X//' << \SHAR_EOF > 'Ifile.sh'
  240. XXex - $1 << EOF
  241. XX1,\$s/^PC/xPC/
  242. XX1,\$s/^BC/xBC/
  243. XX1,\$s/^UP/xUP/
  244. XX1,\$s/^ospeed/xospeed/
  245. XX1,\$s/^LINES/xLINES/
  246. XX1,\$s/^COLS/xCOLS/
  247. XX1,\$s/^tgetflag/xtgetflag/
  248. XX1,\$s/^tgetent/xtgetent/
  249. XX1,\$s/^tgetstr/xtgetstr/
  250. XX1,\$s/^tgetnum/xtgetnum/
  251. XX1,\$s/^tgoto/xtgoto/
  252. XX1,\$s/^tputs/xtputs/
  253. XX1,\$s/^wrefresh/xwrefresh/
  254. XX1,\$s/^initscr/xinitscr/
  255. XX1,\$s/^cbreak/xcbreak/
  256. XX1,\$s/^nl/xnl/
  257. XX1,\$s/^flushinp/xflushinp/
  258. XX1,\$s/^noecho/xnoecho/
  259. XX1,\$s/^savetty/xsavetty/
  260. XX1,\$s/^resetty/xresetty/
  261. XX1,\$s/^echo/xecho/
  262. XX1,\$s/^nocbreak/xnocbreak/
  263. XX1,\$s/^nonl/xnonl/
  264. XX1,\$s/^keypad/xkeypad/
  265. XX1,\$s/^endwin/xendwin/
  266. XX1,\$s/^printw/xprintw/
  267. XX1,\$s/^fixterm/xfixterm/
  268. XX1,\$s/^resetterm/xresetterm/
  269. XX1,\$s/^setterm/xsetterm/
  270. XX1,\$s/^baudrate/xbaudrate/
  271. XXw
  272. XXq
  273. XXEOF
  274. XSHAR_EOF
  275. Xif test 705 -ne "`wc -c < 'Ifile.sh'`"
  276. Xthen
  277. X    echo shar: "error transmitting 'Ifile.sh'" '(should have been 705 characters)'
  278. Xfi
  279. Xfi
  280. Xecho shar: "extracting 'Makefile'" '(3372 characters)'
  281. Xif test -f 'Makefile'
  282. Xthen
  283. X    echo shar: "will not over-write existing file 'Makefile'"
  284. Xelse
  285. Xsed 's/^X//' << \SHAR_EOF > 'Makefile'
  286. XX#                Pcomm
  287. XX#            for AT&T Unix PC 7300/3b1
  288. XX#
  289. XX# valid compile time definitions (CFLAGS) are:
  290. XX#
  291. XX# OLDCURSES    use termcap (in lieu of terminfo) for curses
  292. XX# UNIXPC    use AT&T Unix PC 7300/3b1 specific routines
  293. XX# SGID        retore the real group id before doing anything dangerous
  294. XX#
  295. XX# for systems without getcwd(3) or getopt(3)
  296. XX#
  297. XX#GETCWD = getcwd.o
  298. XX#GETOPT = getopt.o
  299. XX
  300. XXCC = cc -O
  301. XXCFLAGS = -DUNIXPC
  302. XXCURSES = -lcurses
  303. XXLD = ld -s
  304. XXSHAR = shar -a
  305. XXSTARTUP = /lib/crt0s.o
  306. XXSHAREDLIB = shlib_c.ifile
  307. XX
  308. XXOBJECTS = $(GETCWD) $(GETOPT) admin.o chg_dir.o curses.o d_delete.o d_lib.o \
  309. XX    d_manual.o d_menu.o d_print.o d_prompt.o d_revise.o data_log.o \
  310. XX    di_delay.o di_win.o dial.o expand.o help.o info.o init.o input.o \
  311. XX    line_set.o list_dir.o ls_menu.o m_lib.o main.o n_shell.o p_lib.o \
  312. XX    pexit.o port.o redial.o s_axfer.o s_gen.o s_menu.o s_modem.o \
  313. XX    s_prompt.o s_term.o s_tty.o screen.o st_line.o strings.o terminal.o \
  314. XX    x_ascii.o x_batch.o x_menu.o x_rcv.o x_send.o x_win.o xmodem.o
  315. XX
  316. XXOTHERS = setvbuf.o doprnt.o
  317. XX
  318. XXpcomm:    $(OBJECTS) $(OTHERS) $(SHAREDLIB)
  319. XX    $(LD) $(OBJECTS) $(OTHERS) $(CURSES) $(STARTUP) $(SHAREDLIB) -o pcomm
  320. XX
  321. XXlint:
  322. XX    lint $(CFLAGS) *.c
  323. XX
  324. XXshar:
  325. XX    $(SHAR) Readme Release.notes Doc Pcomm.1 Pcomm.dial_dir Pcomm.modem \
  326. XX    Pcomm.param Ifile.sh > pcomm_sh.1
  327. XX    $(SHAR) Makefile dial_dir.h misc.h modem.h param.h status.h xmodem.h \
  328. XX    admin.c chg_dir.c curses.c d_delete.c d_lib.c d_manual.c d_menu.c \
  329. XX    d_print.c > pcomm_sh.2
  330. XX    $(SHAR) d_prompt.c d_revise.c data_log.c di_delay.c di_win.c dial.c \
  331. XX    expand.c getcwd.c getopt.c help.c info.c init.c input.c > pcomm_sh.3
  332. XX    $(SHAR) line_set.c list_dir.c ls_menu.c m_lib.c main.c n_shell.c \
  333. XX    p_lib.c pexit.c port.c redial.c s_axfer.c s_gen.c > pcomm_sh.4
  334. XX    $(SHAR) s_menu.c s_modem.c s_prompt.c s_term.c s_tty.c screen.c \
  335. XX    st_line.c strings.c terminal.c x_ascii.c x_batch.c > pcomm_sh.5
  336. XX    $(SHAR) x_menu.c x_rcv.c x_send.c x_win.c xmodem.c > pcomm_sh.6
  337. XX
  338. XXsetvbuf.o:
  339. XX    ar x /lib/libc.a setvbuf.o
  340. XX
  341. XXdoprnt.o:
  342. XX    ar x /lib/libc.a doprnt.o
  343. XX
  344. XXshlib_c.ifile:
  345. XX    cp /lib/shlib.ifile shlib_c.ifile
  346. XX    sh Ifile.sh shlib_c.ifile
  347. XX
  348. XXadmin.o:    dial_dir.h param.h
  349. XXchg_dir.o:    misc.h
  350. XXcurses.o:    misc.h
  351. XXd_delete.o:    dial_dir.h misc.h param.h
  352. XXd_lib.o:    dial_dir.h param.h status.h
  353. XXd_manual.o:    dial_dir.h
  354. XXd_menu.o:    dial_dir.h misc.h param.h
  355. XXd_print.o:    dial_dir.h misc.h
  356. XXd_prompt.o:    dial_dir.h misc.h
  357. XXd_revise.o:    dial_dir.h misc.h param.h
  358. XXdata_log.o:    misc.h param.h status.h
  359. XXdi_delay.o:    misc.h param.h
  360. XXdi_win.o:    dial_dir.h misc.h modem.h param.h status.h
  361. XXdial.o:        dial_dir.h modem.h param.h status.h
  362. XXhelp.o:        misc.h
  363. XXinit.o:        misc.h status.h
  364. XXline_set.o:    dial_dir.h param.h status.h
  365. XXlist_dir.o:    misc.h
  366. XXls_menu.o:    dial_dir.h misc.h param.h
  367. XXm_lib.o:    modem.h status.h
  368. XXmain.o:        dial_dir.h modem.h param.h status.h
  369. XXp_lib.o:    param.h status.h
  370. XXpexit.o:    dial_dir.h misc.h param.h status.h
  371. XXport.o:        dial_dir.h modem.h status.h
  372. XXredial.o:    dial_dir.h misc.h
  373. XXs_axfer.o:    misc.h param.h
  374. XXs_gen.o:    misc.h param.h
  375. XXs_menu.o:    misc.h
  376. XXs_modem.o:    misc.h modem.h
  377. XXs_prompt.o:    misc.h
  378. XXs_term.o:    misc.h param.h
  379. XXs_tty.o:    misc.h modem.h status.h
  380. XXscreen.o:    param.h status.h
  381. XXst_line.o:    dial_dir.h misc.h modem.h param.h status.h
  382. XXterminal.o:    dial_dir.h modem.h param.h status.h
  383. XXx_ascii.o:    param.h status.h
  384. XXx_batch.o:    misc.h xmodem.h
  385. XXx_menu.o:    misc.h xmodem.h
  386. XXx_rcv.o:    dial_dir.h misc.h xmodem.h
  387. XXx_send.o:    dial_dir.h misc.h status.h xmodem.h
  388. XXx_win.o:    dial_dir.h misc.h status.h xmodem.h
  389. XXxmodem.o:    param.h status.h xmodem.h
  390. XSHAR_EOF
  391. Xif test 3372 -ne "`wc -c < 'Makefile'`"
  392. Xthen
  393. X    echo shar: "error transmitting 'Makefile'" '(should have been 3372 characters)'
  394. Xfi
  395. Xfi
  396. Xecho shar: "extracting 'Pcomm.modem'" '(154 characters)'
  397. Xif test -f 'Pcomm.modem'
  398. Xthen
  399. X    echo shar: "will not over-write existing file 'Pcomm.modem'"
  400. Xelse
  401. Xsed 's/^X//' << \SHAR_EOF > 'Pcomm.modem'
  402. XXTTY_1=ph1;OBM;1200
  403. XXTTY_2=tty000;DIRECT;19200
  404. XXMODEM_1a=OBM;;%;@;
  405. XXMODEM_1b=CONNECT;CONNECT;;;;
  406. XXMODEM_1c=;;;
  407. XXMODEM_2a=DIRECT;;;;
  408. XXMODEM_2b=;;;;;
  409. XXMODEM_2c=;;;
  410. XSHAR_EOF
  411. Xif test 154 -ne "`wc -c < 'Pcomm.modem'`"
  412. Xthen
  413. X    echo shar: "error transmitting 'Pcomm.modem'" '(should have been 154 characters)'
  414. Xfi
  415. Xfi
  416. Xexit 0
  417. X#    End of shell archive
  418. SHAR_EOF
  419. if test 8328 -ne "`wc -c < 'Unixpc.shar'`"
  420. then
  421.     echo shar: "error transmitting 'Unixpc.shar'" '(should have been 8328 characters)'
  422. fi
  423. fi
  424. echo shar: "extracting 'dial_dir.h'" '(815 characters)'
  425. if test -f 'dial_dir.h'
  426. then
  427.     echo shar: "will not over-write existing file 'dial_dir.h'"
  428. else
  429. sed 's/^X//' << \SHAR_EOF > 'dial_dir.h'
  430. X/*
  431. X * The dialing directory structure.  The first eight elements are
  432. X * contained in the pcomm.dial_dir file.
  433. X */
  434. X
  435. X#define NUM_DIR        100
  436. X#define NUM_QUEUE    10
  437. X
  438. Xstruct DIAL_DIR {
  439. X    char    *name[NUM_DIR+1];    /* name of system being called */
  440. X    char    *number[NUM_DIR+1];    /* phone number */
  441. X    int    baud[NUM_DIR+1];    /* baud rate */
  442. X    char    parity[NUM_DIR+1];    /* parity */
  443. X    int    dbits[NUM_DIR+1];    /* data bits */
  444. X    int    sbits[NUM_DIR+1];    /* stop bits */
  445. X    char    duplex[NUM_DIR+1];    /* duplex (F = full, H = half) */
  446. X    char     *index[NUM_DIR+1];    /* command line index (or tty) */
  447. X
  448. X    int    d_entries;        /* number of entries in the file */
  449. X    int    d_cur;            /* the current entry */
  450. X    int    q_num[NUM_QUEUE];    /* entry numbers in the queue */
  451. X    char    q_ld[NUM_QUEUE];    /* LD codes in the queue */
  452. X};
  453. X
  454. X#ifndef MAIN
  455. Xextern struct DIAL_DIR *dir;
  456. X#endif /* MAIN */
  457. SHAR_EOF
  458. if test 815 -ne "`wc -c < 'dial_dir.h'`"
  459. then
  460.     echo shar: "error transmitting 'dial_dir.h'" '(should have been 815 characters)'
  461. fi
  462. fi
  463. echo shar: "extracting 'misc.h'" '(1031 characters)'
  464. if test -f 'misc.h'
  465. then
  466.     echo shar: "will not over-write existing file 'misc.h'"
  467. else
  468. sed 's/^X//' << \SHAR_EOF > 'misc.h'
  469. X/*
  470. X * Definitions to support the home-grown curses functions and to make the
  471. X * old curses routines happy
  472. X */
  473. X
  474. X#define NOPROMOTE
  475. X
  476. X#define mvwattrstr(w,y,x,a,s)    (wmove(w,y,x)==ERR?ERR:wattrstr(w,a,s))
  477. X#define mvwattrch(w,y,x,a,c)    (wmove(w,y,x)==ERR?ERR:wattrch(w,a,c))
  478. X#define mvwattrnum(w,y,x,a,n)    (wmove(w,y,x)==ERR?ERR:wattrnum(w,a,n))
  479. X#define mvattrstr(y,x,a,s)    (wmove(stdscr,y,x)==ERR?ERR:wattrstr(stdscr,a,s))
  480. X#define mvattrch(y,x,a,c)    (wmove(stdscr,y,x)==ERR?ERR:wattrch(stdscr,a,c))
  481. X#define mvattrnum(y,x,a,n)    (wmove(stdscr,y,x)==ERR?ERR:wattrnum(stdscr,a,n))
  482. X#define attrstr(a,s)        wattrstr(stdscr,a,s)
  483. X#define attrch(a,c)        wattrch(stdscr,a,c)
  484. X#define attrnum(a,n)        wattrnum(stdscr,a,n)
  485. X
  486. X#ifdef OLDCURSES
  487. X#ifdef NOPROMOTE
  488. X#define A_BOLD        0
  489. X#define A_BLINK        0
  490. X#define A_REVERSE    1
  491. X#define A_DIM        0
  492. X#define A_STANDOUT    1
  493. X#define A_UNDERLINE    0
  494. X#else /* NOPROMOTE */
  495. X#define A_BOLD        1
  496. X#define A_BLINK        1
  497. X#define A_REVERSE    1
  498. X#define A_DIM        1
  499. X#define A_STANDOUT    1
  500. X#define A_UNDERLINE    1
  501. X#endif /* NOPROMOTE */
  502. X#endif /* OLDCURSES */
  503. SHAR_EOF
  504. if test 1031 -ne "`wc -c < 'misc.h'`"
  505. then
  506.     echo shar: "error transmitting 'misc.h'" '(should have been 1031 characters)'
  507. fi
  508. fi
  509. echo shar: "extracting 'modem.h'" '(1417 characters)'
  510. if test -f 'modem.h'
  511. then
  512.     echo shar: "will not over-write existing file 'modem.h'"
  513. else
  514. sed 's/^X//' << \SHAR_EOF > 'modem.h'
  515. X/*
  516. X * The modem and tty databases.  The first 3 elements make up the tty
  517. X * database, the next 15 make up the modem database.  A "tname" in common
  518. X * with a "mname" link the two together.
  519. X */
  520. X
  521. X#define NUM_TTY        10
  522. X#define NUM_MODEM    10
  523. X
  524. Xstruct MODEM {
  525. X    char     *tty[NUM_TTY];        /* tty names */
  526. X    char    *tname[NUM_TTY];    /* modem name */
  527. X    int    mbaud[NUM_TTY];        /* maximum baud rate */
  528. X
  529. X    char    *mname[NUM_MODEM];    /* modem name (matches tname above) */
  530. X    char    *init[NUM_MODEM];    /* initialization */
  531. X    char    *dial[NUM_MODEM];    /* dial command */
  532. X    char    *suffix[NUM_MODEM];    /* dialing command suffix */
  533. X    char    *hangup[NUM_MODEM];    /* hang up the modem */
  534. X    char    *con_3[NUM_MODEM];    /* 300 baud connect message */
  535. X    char    *con_12[NUM_MODEM];    /* 1200 baud connect message */
  536. X    char    *con_24[NUM_MODEM];    /* 2400 baud connect message */
  537. X    char    *con_48[NUM_MODEM];    /* 4800 baud connect message */
  538. X    char    *con_96[NUM_MODEM];    /* 9600 baud connect message */
  539. X    char    *con_192[NUM_MODEM];    /* 19200 baud connect message */
  540. X    char    *no_con1[NUM_MODEM];    /* no connect #1 */
  541. X    char    *no_con2[NUM_MODEM];    /* no connect #2 */
  542. X    char    *no_con3[NUM_MODEM];    /* no connect #3 */
  543. X    char    *no_con4[NUM_MODEM];    /* no connect #4 */
  544. X
  545. X    int    t_entries;        /* number of tty entries */
  546. X    int    m_entries;        /* number of modem entries */
  547. X    int    t_cur;            /* current tty entry number */
  548. X    int    m_cur;            /* current modem entry number */
  549. X};
  550. X
  551. X#ifndef MAIN
  552. Xextern struct MODEM *modem;
  553. X#endif /* MAIN */
  554. SHAR_EOF
  555. if test 1417 -ne "`wc -c < 'modem.h'`"
  556. then
  557.     echo shar: "error transmitting 'modem.h'" '(should have been 1417 characters)'
  558. fi
  559. fi
  560. echo shar: "extracting 'param.h'" '(2262 characters)'
  561. if test -f 'param.h'
  562. then
  563.     echo shar: "will not over-write existing file 'param.h'"
  564. else
  565. sed 's/^X//' << \SHAR_EOF > 'param.h'
  566. X/*
  567. X * The standard pcomm parameters.  Everything can be altered by using one
  568. X * of pcomm's menus.  Although editing by hand is not encouraged, the
  569. X * pcomm.param file is just an ASCII file.
  570. X */
  571. X
  572. X#define MAX_CDELAY    120
  573. X#define MIN_CDELAY    10
  574. X#define MAX_PAUSE    120
  575. X#define MIN_PAUSE    1
  576. X#define MAX_TIMER    20
  577. X#define MIN_TIMER    2
  578. X
  579. X#define NUM_PARAM    33
  580. X#define LINE_SET    0
  581. X#define TERM_SETUP    4
  582. X#define GEN_SETUP    10
  583. X#define DELAY_TIMES    18
  584. X#define ASCII_SETUP    20
  585. X#define LD_CODES    29
  586. X
  587. Xstruct PARAM {
  588. X                /* 0-3 used in line_set_menu() */
  589. X    int    d_baud;            /* default baud rate */
  590. X    char    d_parity;        /* default parity */
  591. X    int    d_dbits;        /* default data bits */
  592. X    int     d_sbits;        /* default stop bits */
  593. X
  594. X                /* 4-9 used in term_setup() */
  595. X    int    hot;            /* the decimal code for the hot key */
  596. X    char     *ascii_hot;        /* ascii representation of hot key */
  597. X    char     *d_duplex;        /* default duplex */
  598. X    char    *flow;            /* flow control */
  599. X    char    *cr_in;            /* send as carriage return */
  600. X    char    *cr_out;        /* receive carriage return as */
  601. X
  602. X                /* 10-17 used in gen_setup() */
  603. X    char    *logfile;        /* default log file */
  604. X    char    *dumpfile;        /* default screen dump file */
  605. X    char    *strip;            /* strip high bit (translate table) */
  606. X    char    pause_char;        /* pause char synonym */
  607. X    char     cr_char;        /* carriage return char synonym */
  608. X    char     ctrl_char;        /* ctrl char synonym */
  609. X    char     esc_char;        /* escape char synonym */
  610. X    char     *abort;            /* destination of aborted downloads */
  611. X
  612. X                /* 18-19 used in gen_setup() & delay_times() */
  613. X    int    cdelay;            /* connect delay time */
  614. X    int    pause;            /* pause between dialing attempts */
  615. X
  616. X                /* 20-27 used in ascii_xfer_setup() */
  617. X    char    *lecho;            /* echo locally ? */
  618. X    char    *expand;        /* expand blank lines? */
  619. X    int    cr_delay;        /* carriage return delay (ms) */
  620. X    char    *pace;            /* pace the output ? */
  621. X    char    *cr_up;            /* send carriage return as */
  622. X    char    *lf_up;            /* send line feed as */
  623. X    int    timer;            /* Transfer timeout */
  624. X    char    *cr_dn;            /* receive carriage return as */
  625. X    char    *lf_dn;            /* receive line feed as */
  626. X
  627. X                /* 28-31 used in d_revise() */
  628. X    char    *ld_plus;        /* + long distance code */
  629. X    char    *ld_minus;        /* - long distance code */
  630. X    char    *ld_at;            /* @ long distance code */
  631. X    char    *ld_pound;        /* # long distance code */
  632. X};
  633. X
  634. X#ifndef MAIN
  635. Xextern struct PARAM *param;
  636. X#endif /* MAIN */
  637. SHAR_EOF
  638. if test 2262 -ne "`wc -c < 'param.h'`"
  639. then
  640.     echo shar: "error transmitting 'param.h'" '(should have been 2262 characters)'
  641. fi
  642. fi
  643. echo shar: "extracting 'status.h'" '(631 characters)'
  644. if test -f 'status.h'
  645. then
  646.     echo shar: "will not over-write existing file 'status.h'"
  647. else
  648. sed 's/^X//' << \SHAR_EOF > 'status.h'
  649. X/*
  650. X * The location of the support files, status flags, and other various
  651. X * changeable things.
  652. X */
  653. X
  654. Xstruct STATUS {
  655. X    char    *p_path;        /* pcomm.param file */
  656. X    char    *d_path;        /* pcomm.dial_dir file */
  657. X    char    *m_path;        /* pcomm.modem file */
  658. X    char    *lock_path;        /* UUCP lock file */
  659. X    char    *vs_path;        /* virtual screen file */
  660. X    char    *log_path;        /* data logging file */
  661. X    int    fd;            /* file descriptor for tty */
  662. X    int    log;            /* status of log option */
  663. X    int    print;            /* status of print option */
  664. X    int    msg;            /* the 'msg' status */
  665. X    int    pid;            /* the pid of the child process */
  666. X};
  667. X
  668. X#ifndef MAIN
  669. Xextern struct STATUS *status;
  670. X#endif /* MAIN */
  671. SHAR_EOF
  672. if test 631 -ne "`wc -c < 'status.h'`"
  673. then
  674.     echo shar: "error transmitting 'status.h'" '(should have been 631 characters)'
  675. fi
  676. fi
  677. echo shar: "extracting 'xmodem.h'" '(373 characters)'
  678. if test -f 'xmodem.h'
  679. then
  680.     echo shar: "will not over-write existing file 'xmodem.h'"
  681. else
  682. sed 's/^X//' << \SHAR_EOF > 'xmodem.h'
  683. X/*
  684. X * Definitions for the xmodem stuff.
  685. X */
  686. X
  687. X#define MAX_ERRORS     10
  688. X
  689. X#define SOH        1
  690. X#define STX        2
  691. X#define EOT        4
  692. X#define ACK        6
  693. X#define NAK        21
  694. X#define CAN        24
  695. X#define CTRLZ        26
  696. X
  697. X#define PROTOCOLS    6
  698. X#define XMODEM        0
  699. X#define XMODEM_1k    1
  700. X#define MODEM7        2
  701. X#define YMODEM        3
  702. X#define YMODEM_G    4
  703. X#define XASCII        5
  704. X
  705. X#define ABORT        (-1)
  706. X#define ERROR        (-2)
  707. X#define CANCEL        (-3)
  708. SHAR_EOF
  709. if test 373 -ne "`wc -c < 'xmodem.h'`"
  710. then
  711.     echo shar: "error transmitting 'xmodem.h'" '(should have been 373 characters)'
  712. fi
  713. fi
  714. echo shar: "extracting 'admin.c'" '(2871 characters)'
  715. if test -f 'admin.c'
  716. then
  717.     echo shar: "will not over-write existing file 'admin.c'"
  718. else
  719. sed 's/^X//' << \SHAR_EOF > 'admin.c'
  720. X/*
  721. X * Perform administrative functions.  Check to see if the user has
  722. X * permission to make long distance calls, and record all phone calls
  723. X * made by pcomm.
  724. X */
  725. X
  726. X#undef LOG_CALLS
  727. X#undef LIMIT_LD
  728. X
  729. X#define LOGFILE "/usr/adm/phone.calls"
  730. X#define GRPNAME "uucp"
  731. X
  732. X#include <stdio.h>
  733. X#include <grp.h>
  734. X#include "dial_dir.h"
  735. X#include "param.h"
  736. X
  737. X/*
  738. X * Make a log of all calls made by pcomm.  The argument is the index
  739. X * into the queue.
  740. X */
  741. X
  742. Xint
  743. Xlog_calls(i)
  744. Xint i;
  745. X{
  746. X#ifdef LOG_CALLS
  747. X    FILE *fp;
  748. X    char *number, *build_num(), *date, *ctime(), *getlogin();
  749. X    long now, time();
  750. X    void error_win();
  751. X                    /* build the complete phone number */
  752. X    number = build_num(i);
  753. X                    /* build date and time */
  754. X    time(&now);
  755. X    date = ctime(&now);
  756. X    date[10] = NULL;
  757. X    date[16] = NULL;
  758. X
  759. X    if (!(fp = fopen(LOGFILE, "a+")))
  760. X        error_win(1, "Can't open phone log file", "Contact your system administrator");
  761. X
  762. X    fprintf(fp, "pcomm: %s called %s at %s on %s\n", getlogin(), number, &date[11], date);
  763. X    fclose(fp);
  764. X#endif /* LOG_CALLS */
  765. X    return (0);
  766. X}
  767. X
  768. X/*
  769. X * Check to see if long distance (toll) call is authorized.  The argument
  770. X * is the index into the queue.
  771. X */
  772. X
  773. Xint
  774. Xlimit_ld(i)
  775. Xint i;
  776. X{
  777. X#ifdef LIMIT_LD
  778. X    char *number, *build_num(), *name, *getlogin();
  779. X    struct group *getgrnam(), *grpbuf;
  780. X
  781. X                    /* if no group, don't bother */
  782. X    grpbuf = getgrnam(GRPNAME);
  783. X    if (!grpbuf || !*grpbuf->gr_mem)
  784. X        return(0);
  785. X                    /* are you in the group? */
  786. X    name = getlogin();
  787. X    for (; *grpbuf->gr_mem != NULL; grpbuf->gr_mem++) {
  788. X        if (!strcmp(*grpbuf->gr_mem, name))
  789. X            return(0);
  790. X    }
  791. X                    /* numbers only... */
  792. X    number = build_num(i);
  793. X
  794. X    /*
  795. X     * Very site specific!!!  We use a '9' to get an outside line,
  796. X     * so any 9 followed by a 1 is a toll call (except for 1-800
  797. X     * numbers).
  798. X     */
  799. X    if (!strncmp(number, "91", 2) && strncmp(number, "91800", 5)) {
  800. X        error_win(0, "You are not authorized to place long distance \(toll\) calls", NULL);
  801. X        return(1);
  802. X    }
  803. X
  804. X    if (*number == NULL) {
  805. X        error_win(0, "You are not authorized direct access to the line", "Use the automatic dialing feature");
  806. X        return(1);
  807. X    }
  808. X#endif /* LIMIT_LD */
  809. X    return(0);
  810. X}
  811. X
  812. X#ifdef LOG_CALLS || LIMIT_LD
  813. X/*
  814. X * Put together the complete phone number but strip out the extraneous
  815. X * characters.
  816. X */
  817. X
  818. Xchar *
  819. Xbuild_num(i)
  820. Xint i;
  821. X{
  822. X    int j;
  823. X    char *t, temp[40], *strcpy(), *strcat();
  824. X    static char ans[40];
  825. X
  826. X    temp[0] = NULL;
  827. X                    /* add LD codes ? */
  828. X    switch (dir->q_ld[i]) {
  829. X        case 0:
  830. X            break;
  831. X        case '+':
  832. X            strcpy(temp, param->ld_plus);
  833. X            break;
  834. X        case '-':
  835. X            strcpy(temp, param->ld_minus);
  836. X            break;
  837. X        case '@':
  838. X            strcpy(temp, param->ld_at);
  839. X            break;
  840. X        case '#':
  841. X            strcpy(temp, param->ld_pound);
  842. X            break;
  843. X    }
  844. X                    /* add the number */
  845. X    strcat(temp, dir->number[dir->q_num[i]]);
  846. X
  847. X                    /* copy only digits */
  848. X    j = 0;
  849. X    t = temp;
  850. X    while (*t) {
  851. X        if (*t >= '0' && *t <= '9')
  852. X            ans[j++] = *t;
  853. X        t++;
  854. X    }
  855. X    ans[j] = NULL;
  856. X
  857. X    return(ans);
  858. X}
  859. X#endif /* LOG_CALLS || LIMIT_LD */
  860. SHAR_EOF
  861. if test 2871 -ne "`wc -c < 'admin.c'`"
  862. then
  863.     echo shar: "error transmitting 'admin.c'" '(should have been 2871 characters)'
  864. fi
  865. fi
  866. echo shar: "extracting 'chg_dir.c'" '(1363 characters)'
  867. if test -f 'chg_dir.c'
  868. then
  869.     echo shar: "will not over-write existing file 'chg_dir.c'"
  870. else
  871. sed 's/^X//' << \SHAR_EOF > 'chg_dir.c'
  872. X/*
  873. X * Open a window to prompt for a new directory.  Checks to see if the
  874. X * directory exists, but doesn't move to there (yet).  Returns the path
  875. X * to the new directory, or NULL if you chickened out.
  876. X */
  877. X
  878. X#include <curses.h>
  879. X#include "misc.h"
  880. X
  881. Xchar *
  882. Xchange_dir(fd)
  883. Xint fd;
  884. X{
  885. X    WINDOW *ch_win, *newwin();
  886. X    int got_it;
  887. X    char *ans, *dir, *expand(), *cwd, *getcwd(), cwdbuf[200];
  888. X    char *get_str();
  889. X    void free_ptr();
  890. X
  891. X    cwd = getcwd(cwdbuf, 200);
  892. X
  893. X    ch_win = newwin(6, 70, 5, 5);
  894. X
  895. X    mvwprintw(ch_win, 2, 4, "Current directory: %s", cwd);
  896. X    mvwaddstr(ch_win, 3, 4, "New directory: ");
  897. X    box(ch_win, '|', '-');
  898. X
  899. X    mvwattrstr(ch_win, 0, 3, A_BOLD, " Change directory ");
  900. X    wmove(ch_win, 3, 19);
  901. X    wrefresh(ch_win);
  902. X                    /* get the answer */
  903. X    got_it = 0;
  904. X    while ((ans = get_str(ch_win, 60, NULL, "     ")) != NULL) {
  905. X        if (*ans == NULL)
  906. X            break;
  907. X                    /* expand the input */
  908. X        dir = expand(ans);
  909. X                    /* if it exists */
  910. X        if (!access(dir, 1)) {
  911. X            got_it++;
  912. X            break;
  913. X        }
  914. X        beep();
  915. X        mvwattrstr(ch_win, 4, 15, A_BOLD, "No such directory or no access permission");
  916. X        wrefresh(ch_win);
  917. X        wait_key(ch_win, 3);
  918. X                    /* cleanup the mess */
  919. X        clear_line(ch_win, 3, 19, 1);
  920. X        clear_line(ch_win, 4, 14, 1);
  921. X        wmove(ch_win, 3, 19);
  922. X        wrefresh(ch_win);
  923. X        free_ptr(dir);
  924. X    }
  925. X    if (fd == -1) {
  926. X        werase(ch_win);
  927. X        wrefresh(ch_win);
  928. X    }
  929. X    delwin(ch_win);
  930. X    if (got_it)
  931. X        return(dir);
  932. X    return(NULL);
  933. X}
  934. SHAR_EOF
  935. if test 1363 -ne "`wc -c < 'chg_dir.c'`"
  936. then
  937.     echo shar: "error transmitting 'chg_dir.c'" '(should have been 1363 characters)'
  938. fi
  939. fi
  940. echo shar: "extracting 'curses.c'" '(7649 characters)'
  941. if test -f 'curses.c'
  942. then
  943.     echo shar: "will not over-write existing file 'curses.c'"
  944. else
  945. sed 's/^X//' << \SHAR_EOF > 'curses.c'
  946. X/*
  947. X * Miscellaneous curses routines.
  948. X */
  949. X
  950. X#include <stdio.h>
  951. X#include <curses.h>
  952. X#include <signal.h>
  953. X#include <setjmp.h>
  954. X#ifdef OLDCURSES
  955. X#include <fcntl.h>
  956. X#else /* OLDCURSES */
  957. X#include <term.h>
  958. X#endif /* OLDCURSES */
  959. X#include "misc.h"
  960. X
  961. X/*
  962. X * Get a string from a window.  Similar to wgetstr(), except we limit
  963. X * the length, return a NULL (not pointer to NULL) on ESC key, beep
  964. X * at any character in 'disallow' string, and beep at any character not
  965. X * in 'allow'. (It doesn't make sense to use both 'allow' and 'disallow'
  966. X * at the same time)
  967. X */
  968. X
  969. Xchar *
  970. Xget_str(win, num, allow, disallow)
  971. XWINDOW *win;
  972. Xint num;
  973. Xchar *allow, *disallow;
  974. X{
  975. X    int count, x, y;
  976. X    char ans, *strchr();
  977. X    static char buf[80];
  978. X
  979. X    count = 0;
  980. X    while ((ans = wgetch(win)) != '\r') {
  981. X                    /* do our own backspace */
  982. X        if (ans == 8) {
  983. X            if (!count) {
  984. X                beep();
  985. X                continue;
  986. X            }
  987. X            count--;
  988. X            buf[count] = NULL;
  989. X            getyx(win, y, x);
  990. X            x--;
  991. X            wmove(win, y, x);
  992. X            waddch(win, ' ');
  993. X            wmove(win, y, x);
  994. X            wrefresh(win);
  995. X            continue;
  996. X        }
  997. X                    /* an ESC anywhere in the string */
  998. X        if (ans == 27)
  999. X            return(NULL);
  1000. X
  1001. X                    /* illegal character ? */
  1002. X        if (disallow != NULL && strchr(disallow, ans)) {
  1003. X            beep();
  1004. X            continue;
  1005. X        }
  1006. X        if (allow != NULL && !strchr(allow, ans)) {
  1007. X            beep();
  1008. X            continue;
  1009. X        }
  1010. X                    /* exceeded the max ? */
  1011. X        if (count == num) {
  1012. X            beep();
  1013. X            continue;
  1014. X        }
  1015. X
  1016. X        buf[count] = ans;
  1017. X        waddch(win, ans);
  1018. X        wrefresh(win);
  1019. X        count++;
  1020. X    }
  1021. X    buf[count] = NULL;
  1022. X    return(buf);
  1023. X}
  1024. X
  1025. X/*
  1026. X * Get a number from a window.  We limit the length and return a -1
  1027. X * on ESC key.
  1028. X */
  1029. X
  1030. Xint
  1031. Xget_num(win, num)
  1032. XWINDOW *win;
  1033. Xint num;
  1034. X{
  1035. X    int count, x, y, number;
  1036. X    char ans, buf[80];
  1037. X
  1038. X    count = 0;
  1039. X    while ((ans = wgetch(win)) != '\r') {
  1040. X                    /* do our own backspace */
  1041. X        if (ans == 8) {
  1042. X            if (!count) {
  1043. X                beep();
  1044. X                continue;
  1045. X            }
  1046. X            count--;
  1047. X            buf[count] = NULL;
  1048. X            getyx(win, y, x);
  1049. X            x--;
  1050. X            wmove(win, y, x);
  1051. X            waddch(win, ' ');
  1052. X            wmove(win, y, x);
  1053. X            wrefresh(win);
  1054. X            continue;
  1055. X        }
  1056. X                    /* an ESC anywhere in the string */
  1057. X        if (ans == 27)
  1058. X            return(-1);
  1059. X                    /* only digits are allowed */
  1060. X        if (ans < '0' || ans > '9') {
  1061. X            beep();
  1062. X            continue;
  1063. X        }
  1064. X                    /* exceeded the max ? */
  1065. X        if (count == num) {
  1066. X            beep();
  1067. X            continue;
  1068. X        }
  1069. X
  1070. X        buf[count] = ans;
  1071. X        waddch(win, ans);
  1072. X        wrefresh(win);
  1073. X        count++;
  1074. X    }
  1075. X    buf[count] = NULL;
  1076. X    number = atoi(buf);
  1077. X    return(number);
  1078. X}
  1079. X
  1080. X/*
  1081. X * Change video attributes while printing a string.  The use of the
  1082. X * pre-processor definition NOPROMOTE (located in misc.h) means that
  1083. X * strings will be printed without any special video attribute if the
  1084. X * requested capability doesn't exist.
  1085. X */
  1086. X
  1087. Xwattrstr(win, attr, str)
  1088. XWINDOW *win;
  1089. Xint attr;
  1090. Xchar *str;
  1091. X{
  1092. X    int do_it;
  1093. X                    /* if nothing, do nothing */
  1094. X    if (str == NULL || *str == NULL)
  1095. X        return(0);
  1096. X
  1097. X#ifdef OLDCURSES
  1098. X    if (attr)
  1099. X        wstandout(win);
  1100. X    waddstr(win, str);
  1101. X    if (attr)
  1102. X        wstandend(win);
  1103. X#else /* OLDCURSES */
  1104. X#ifdef NOPROMOTE
  1105. X                    /* does the capability exist ? */
  1106. X    do_it = 0;
  1107. X    if ((attr & A_STANDOUT) && enter_standout_mode)
  1108. X        do_it++;
  1109. X    if ((attr & A_UNDERLINE) && enter_underline_mode)
  1110. X        do_it++;
  1111. X    if ((attr & A_REVERSE) && (enter_reverse_mode || enter_standout_mode))
  1112. X        do_it++;
  1113. X    if ((attr & A_BLINK) && enter_blink_mode)
  1114. X        do_it++;
  1115. X    if ((attr & A_BOLD) && enter_bold_mode)
  1116. X        do_it++;
  1117. X    if ((attr & A_DIM) && enter_dim_mode)
  1118. X        do_it++;
  1119. X#else /* NOPROMOTE */
  1120. X    do_it = 1;
  1121. X#endif /* NOPROMOTE */
  1122. X
  1123. X    if (do_it)
  1124. X        wattron(win, attr);
  1125. X                    /* print the string */
  1126. X    waddstr(win, str);
  1127. X    if (do_it)
  1128. X        wattroff(win, attr);
  1129. X#endif /* OLDCURSES */
  1130. X    return(0);
  1131. X}
  1132. X
  1133. X/*
  1134. X * Change video attributes while printing a character.
  1135. X */
  1136. X
  1137. Xwattrch(win, attr, c)
  1138. XWINDOW *win;
  1139. Xint attr;
  1140. Xchar c;
  1141. X{
  1142. X    int do_it;
  1143. X
  1144. X    if (c == NULL)
  1145. X        return(0);
  1146. X#ifdef OLDCURSES
  1147. X    if (attr)
  1148. X        wstandout(win);
  1149. X    waddch(win, c);
  1150. X    if (attr)
  1151. X        wstandend(win);
  1152. X#else /* OLDCURSES */
  1153. X#ifdef NOPROMOTE
  1154. X                    /* does the capability exist ? */
  1155. X    do_it = 0;
  1156. X    if ((attr & A_STANDOUT) && enter_standout_mode)
  1157. X        do_it++;
  1158. X    if ((attr & A_UNDERLINE) && enter_underline_mode)
  1159. X        do_it++;
  1160. X    if ((attr & A_REVERSE) && (enter_reverse_mode || enter_standout_mode))
  1161. X        do_it++;
  1162. X    if ((attr & A_BLINK) && enter_blink_mode)
  1163. X        do_it++;
  1164. X    if ((attr & A_BOLD) && enter_bold_mode)
  1165. X        do_it++;
  1166. X    if ((attr & A_DIM) && enter_dim_mode)
  1167. X        do_it++;
  1168. X#else /* NOPROMOTE */
  1169. X    do_it = 1;
  1170. X#endif /* NOPROMOTE */
  1171. X
  1172. X    if (do_it)
  1173. X        wattron(win, attr);
  1174. X                    /* print the character */
  1175. X    waddch(win, c);
  1176. X    if (do_it)
  1177. X        wattroff(win, attr);
  1178. X#endif /* OLDCURSES */
  1179. X    return(0);
  1180. X}
  1181. X
  1182. X
  1183. X/*
  1184. X * Change video attributes while printing a number.
  1185. X */
  1186. X
  1187. Xwattrnum(win, attr, num)
  1188. XWINDOW *win;
  1189. Xint attr, num;
  1190. X{
  1191. X    int do_it;
  1192. X    char buf[20];
  1193. X
  1194. X    sprintf(buf, "%d", num);
  1195. X
  1196. X#ifdef OLDCURSES
  1197. X    if (attr)
  1198. X        wstandout(win);
  1199. X    waddstr(win, buf);
  1200. X    if (attr)
  1201. X        wstandend(win);
  1202. X#else /* OLDCURSES */
  1203. X#ifdef NOPROMOTE
  1204. X                    /* does the capability exist ? */
  1205. X    do_it = 0;
  1206. X    if ((attr & A_STANDOUT) && enter_standout_mode)
  1207. X        do_it++;
  1208. X    if ((attr & A_UNDERLINE) && enter_underline_mode)
  1209. X        do_it++;
  1210. X    if ((attr & A_REVERSE) && (enter_reverse_mode || enter_standout_mode))
  1211. X        do_it++;
  1212. X    if ((attr & A_BLINK) && enter_blink_mode)
  1213. X        do_it++;
  1214. X    if ((attr & A_BOLD) && enter_bold_mode)
  1215. X        do_it++;
  1216. X    if ((attr & A_DIM) && enter_dim_mode)
  1217. X        do_it++;
  1218. X#else /* NOPROMOTE */
  1219. X    do_it = 1;
  1220. X#endif /* NOPROMOTE */
  1221. X
  1222. X    if (do_it)
  1223. X        wattron(win, attr);
  1224. X                    /* print the character */
  1225. X    waddstr(win, buf);
  1226. X    if (do_it)
  1227. X        wattroff(win, attr);
  1228. X#endif /* OLDCURSES */
  1229. X    return(0);
  1230. X}
  1231. X
  1232. X/*
  1233. X * Prompt for a Yes or No answer.  Echo the single key input as words.
  1234. X * Handle the funny cursor movement problems with magic cookie terminals.
  1235. X * Returns a 1 on yes.
  1236. X */
  1237. X
  1238. Xint
  1239. Xyes_prompt(win, y, x, attr, str)
  1240. XWINDOW *win;
  1241. Xint y, x, attr;
  1242. Xchar *str;
  1243. X{
  1244. X    int save, ret_code;
  1245. X    char new_str[80], *strcpy(), *strcat();
  1246. X                    /* build and display the prompt */
  1247. X    strcpy(new_str, str);
  1248. X    strcat(new_str, "? (y/n):");
  1249. X    mvwattrstr(win, y, x, attr, new_str);
  1250. X    wmove(win, y, strlen(new_str)+x+2);
  1251. X    wrefresh(win);
  1252. X
  1253. X    ret_code = 0;
  1254. X    save = wgetch(win);
  1255. X    if (save == 'y' || save == 'Y') {
  1256. X        waddstr(win, "Yes");
  1257. X        ret_code = 1;
  1258. X    }
  1259. X    else
  1260. X        waddstr(win, "No");
  1261. X
  1262. X    wrefresh(win);
  1263. X    return(ret_code);
  1264. X}
  1265. X
  1266. X/*
  1267. X * Handy routine for clear-to-end-of-line.  Fixes up the box if requested.
  1268. X */
  1269. X
  1270. Xint
  1271. Xclear_line(win, y, x, re_box)
  1272. XWINDOW *win;
  1273. Xint y, x, re_box;
  1274. X{
  1275. X    if (wmove(win, y, x) == ERR)
  1276. X        return(ERR);
  1277. X
  1278. X    wclrtoeol(win);
  1279. X
  1280. X    if (re_box) {
  1281. X        mvwaddch(win, y, win->_maxx-1, '|');
  1282. X        wmove(win, y, x);
  1283. X    }
  1284. X    return(0);
  1285. X}
  1286. X
  1287. X/*
  1288. X * Wait for a key or time out.  Returns a -1 on timeout.
  1289. X */
  1290. X
  1291. Xjmp_buf wk_jmp;
  1292. X
  1293. Xint
  1294. Xwait_key(win, sec)
  1295. XWINDOW *win;
  1296. Xunsigned int sec;
  1297. X{
  1298. X    int c, force_wk();
  1299. X    unsigned int alarm();
  1300. X
  1301. X    signal(SIGALRM, force_wk);
  1302. X    if (setjmp(wk_jmp))
  1303. X        return(-1);
  1304. X    alarm(sec);
  1305. X    c = wgetch(win);
  1306. X    alarm(0);
  1307. X    return(c);
  1308. X}
  1309. Xint
  1310. Xforce_wk(dummy)
  1311. Xint dummy;
  1312. X{
  1313. X    void longjmp();
  1314. X
  1315. X    longjmp(wk_jmp, 1);
  1316. X}
  1317. X
  1318. X/*
  1319. X * Here are some routines that are probably missing from the older
  1320. X * flavors of curses(3)
  1321. X */
  1322. X
  1323. X#ifdef OLDCURSES
  1324. X/*
  1325. X * Make the terminal bell go off
  1326. X */
  1327. X
  1328. Xint
  1329. Xbeep()
  1330. X{
  1331. X    fputc(7, stderr);
  1332. X    return(0);
  1333. X}
  1334. X
  1335. X/*
  1336. X * Fix the stdin so that a read is satisfied immediately.  When read()
  1337. X * is called it returns the character in the queue, or an error if no
  1338. X * key was pressed.  The window argument is not used!
  1339. X */
  1340. X
  1341. Xint
  1342. Xnodelay(win, flag)
  1343. XWINDOW *win;
  1344. Xint flag;
  1345. X{
  1346. X    if (flag)
  1347. X        fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) | O_NDELAY);
  1348. X    else
  1349. X        fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) & ~O_NDELAY);
  1350. X    return(0);
  1351. X}
  1352. X
  1353. X/*
  1354. X * Take the terminal out of the "curses mode"
  1355. X */
  1356. X
  1357. Xint
  1358. Xresetterm()
  1359. X{
  1360. X    resetty();
  1361. X    return(0);
  1362. X}
  1363. X
  1364. X/*
  1365. X * Put the terminal back into the "curses mode"
  1366. X */
  1367. X
  1368. Xint
  1369. Xmyputchar(c)
  1370. Xchar c;
  1371. X{
  1372. X    putchar(c);
  1373. X}
  1374. Xint
  1375. Xfixterm()
  1376. X{
  1377. X    tputs(TI, 1, myputchar);
  1378. X    tputs(VS, 1, myputchar);
  1379. X    nonl();
  1380. X    crmode();
  1381. X    noecho();
  1382. X    return(0);
  1383. X}
  1384. X#endif /* OLDCURSES */
  1385. SHAR_EOF
  1386. if test 7649 -ne "`wc -c < 'curses.c'`"
  1387. then
  1388.     echo shar: "error transmitting 'curses.c'" '(should have been 7649 characters)'
  1389. fi
  1390. fi
  1391. echo shar: "extracting 'd_delete.c'" '(1987 characters)'
  1392. if test -f 'd_delete.c'
  1393. then
  1394.     echo shar: "will not over-write existing file 'd_delete.c'"
  1395. else
  1396. sed 's/^X//' << \SHAR_EOF > 'd_delete.c'
  1397. X/*
  1398. X * The delete option of the dialing directory.  Prompts for saving
  1399. X * changes to disk. A return code of 1 means that entries were deleted.
  1400. X */
  1401. X
  1402. X#include <stdio.h>
  1403. X#include <curses.h>
  1404. X#include "dial_dir.h"
  1405. X#include "misc.h"
  1406. X#include "param.h"
  1407. X
  1408. Xint
  1409. Xdelete()
  1410. X{
  1411. X    WINDOW *d_win, *newwin();
  1412. X    int i, first, last;
  1413. X    void free_ptr();
  1414. X    extern char *null_ptr;
  1415. X    
  1416. X    d_win = newwin(6, 32, 10, 15);
  1417. X
  1418. X    mvwaddstr(d_win, 2, 2, "Delete entry:     thru:");
  1419. X    box(d_win, '|', '-');
  1420. X    wmove(d_win, 2, 16);
  1421. X    wrefresh(d_win);
  1422. X                    /* get the first of the range */
  1423. X    while ((first = get_num(d_win, 3)) != -1) {
  1424. X        if (first > 0 && first <= NUM_DIR)
  1425. X            break;
  1426. X        mvwaddstr(d_win, 2, 16, "   ");
  1427. X        wmove(d_win, 2, 16);
  1428. X        beep();
  1429. X        wrefresh(d_win);
  1430. X    }
  1431. X    if (first == -1) {
  1432. X        delwin(d_win);
  1433. X        return(0);
  1434. X    }
  1435. X                    /* get the last of the range */
  1436. X    wmove(d_win, 2, 26);
  1437. X    wrefresh(d_win);
  1438. X    while ((last = get_num(d_win, 3)) != -1) {
  1439. X        if ((first <= last && last <= NUM_DIR) || last == 0)
  1440. X            break;
  1441. X        mvwaddstr(d_win, 2, 26, "   ");
  1442. X        wmove(d_win, 2, 26);
  1443. X        beep();
  1444. X        wrefresh(d_win);
  1445. X    }
  1446. X    if (last == -1) {
  1447. X        delwin(d_win);
  1448. X        return(0);
  1449. X    }
  1450. X                    /* if "last" omitted, echo "first" */
  1451. X    if (!last) {
  1452. X        last = first;
  1453. X        mvwprintw(d_win, 2, 26, "%d", first);
  1454. X        wrefresh(d_win);
  1455. X    }
  1456. X                    /* save to disk? */
  1457. X    if (yes_prompt(d_win, 3, 2, A_BOLD, "Are you sure")) {
  1458. X                    /* delete from the physical file */
  1459. X        if (del_dir(first, last)) {
  1460. X            touchwin(d_win);
  1461. X            wrefresh(d_win);
  1462. X        }
  1463. X        /*
  1464. X         * We don't really care if del_dir() fails because we still
  1465. X         * change the version in memory.
  1466. X         */
  1467. X        for (i=first; i<=last; i++) {
  1468. X            free_ptr(dir->name[i]);
  1469. X            free_ptr(dir->number[i]);
  1470. X            free_ptr(dir->index[i]);
  1471. X            dir->name[i] = null_ptr;
  1472. X            dir->number[i] = null_ptr;
  1473. X            dir->baud[i] = param->d_baud;
  1474. X            dir->parity[i] = param->d_parity;
  1475. X            dir->dbits[i] = param->d_dbits;
  1476. X            dir->sbits[i] = param->d_sbits;
  1477. X            dir->duplex[i] = *param->d_duplex;
  1478. X            dir->index[i] = null_ptr;
  1479. X        }
  1480. X        delwin(d_win);
  1481. X        return(1);
  1482. X    }
  1483. X    delwin(d_win);
  1484. X    return(0);
  1485. X}
  1486. SHAR_EOF
  1487. if test 1987 -ne "`wc -c < 'd_delete.c'`"
  1488. then
  1489.     echo shar: "error transmitting 'd_delete.c'" '(should have been 1987 characters)'
  1490. fi
  1491. fi
  1492. echo shar: "extracting 'd_lib.c'" '(6469 characters)'
  1493. if test -f 'd_lib.c'
  1494. then
  1495.     echo shar: "will not over-write existing file 'd_lib.c'"
  1496. else
  1497. sed 's/^X//' << \SHAR_EOF > 'd_lib.c'
  1498. X/*
  1499. X * Routines to manipulate the dialing directory file pcomm.dial_dir
  1500. X */
  1501. X
  1502. X#include <stdio.h>
  1503. X#include "dial_dir.h"
  1504. X#include "param.h"
  1505. X#include "status.h"
  1506. X
  1507. X/*
  1508. X * Read the dialing directory.  Returns a pointer to a static area
  1509. X * containing the DIAL_DIR structure.  All of the entries are created
  1510. X * reguardless of the number of physical entries in the file.  Element
  1511. X * number zero is reserved for the "manual" entry.  All errors are fatal.
  1512. X */
  1513. X
  1514. Xstruct DIAL_DIR *
  1515. Xread_dir()
  1516. X{
  1517. X    FILE *fp;
  1518. X    int i, j, oops;
  1519. X    char *strdup(), buf[80], *temp_token, *str, *str_tok(), token[20];
  1520. X    char message[80], *sep;
  1521. X    static struct DIAL_DIR d;
  1522. X    void error_win();
  1523. X    extern char *null_ptr;
  1524. X
  1525. X    if (!(fp = fopen(status->d_path, "r"))) {
  1526. X        sprintf(buf, "'%s' for read", status->d_path);
  1527. X        error_win(1, "Can't open dialing directory file", buf);
  1528. X    }
  1529. X
  1530. X    sep = ";;---;;\n";
  1531. X    i = 0;
  1532. X    oops = 0;
  1533. X    while (fgets(buf, 80, fp) != NULL) {
  1534. X        i++;
  1535. X        if (i > NUM_DIR)
  1536. X            break;
  1537. X                    /* get the token */
  1538. X        if (!(temp_token = str_tok(buf, '='))) {
  1539. X            sprintf(message, "is missing a token at line %d", i);
  1540. X            oops++;
  1541. X            break;
  1542. X        }
  1543. X        /*
  1544. X         * Parse the rest of the line.  This is similar to using
  1545. X         * the "real" strtok() function, but my version returns
  1546. X         * a null pointer if the parameter is missing.  Note the
  1547. X         * array of field separators.
  1548. X         */
  1549. X        for (j=0; j<8; j++) {
  1550. X            if (!(str = str_tok((char *) NULL, sep[j]))) {
  1551. X                sprintf(message, "is missing a parameter at line %d", i);
  1552. X                oops++;
  1553. X                break;
  1554. X            }
  1555. X            switch(j) {
  1556. X                case 0:
  1557. X                    d.name[i] = strdup(str);
  1558. X                    break;
  1559. X                case 1:
  1560. X                    d.number[i] = strdup(str);
  1561. X                    break;
  1562. X                case 2:
  1563. X                    d.baud[i] = atoi(str);
  1564. X                    break;
  1565. X                case 3:
  1566. X                    d.parity[i] = *str;
  1567. X                    break;
  1568. X                case 4:
  1569. X                    d.dbits[i] = atoi(str);
  1570. X                    break;
  1571. X                case 5:
  1572. X                    d.sbits[i] = atoi(str);
  1573. X                    break;
  1574. X                case 6:
  1575. X                    d.duplex[i] = *str;
  1576. X                    break;
  1577. X                case 7:
  1578. X                    d.index[i] = strdup(str);
  1579. X                    break;
  1580. X            }
  1581. X        }
  1582. X        if (oops)
  1583. X            break;
  1584. X                    /* sanity checking */
  1585. X        sprintf(token, "DIR_%d", i);
  1586. X        if (strcmp(temp_token, token)) {
  1587. X            sprintf(message, "is corrupted at line %d", i);
  1588. X            oops++;
  1589. X            break;
  1590. X        }
  1591. X    }
  1592. X    fclose(fp);
  1593. X
  1594. X    if (oops) {
  1595. X        sprintf(buf, "Directory file '%s'", status->d_path);
  1596. X        error_win(1, buf, message);
  1597. X    }
  1598. X    d.d_entries = i;
  1599. X                    /* fill in the rest with defaults */
  1600. X    i++;
  1601. X    for (; i<=NUM_DIR; i++) {
  1602. X        d.name[i] = null_ptr;
  1603. X        d.number[i] = null_ptr;
  1604. X        d.baud[i] = param->d_baud;
  1605. X        d.parity[i] = param->d_parity;
  1606. X        d.dbits[i] = param->d_dbits;
  1607. X        d.sbits[i] = param->d_sbits;
  1608. X        d.duplex[i] = *param->d_duplex;
  1609. X        d.index[i] = null_ptr;
  1610. X    }
  1611. X                    /* create an empty "manual" entry */
  1612. X    d.name[0] = null_ptr;
  1613. X    d.number[0] = null_ptr;
  1614. X    d.baud[0] = param->d_baud;
  1615. X    d.parity[0] = param->d_parity;
  1616. X    d.dbits[0] = param->d_dbits;
  1617. X    d.sbits[0] = param->d_sbits;
  1618. X    d.duplex[0] = *param->d_duplex;
  1619. X    d.index[0] = null_ptr;
  1620. X                    /* create an empty queue */
  1621. X    for (i=0; i<NUM_QUEUE; i++) {
  1622. X        d.q_ld[i] = NULL;
  1623. X        d.q_num[i] = -1;
  1624. X    }
  1625. X                    /* the startup d_cur is 0 */
  1626. X    d.d_cur = 0;
  1627. X    return(&d);
  1628. X}
  1629. X
  1630. X/*
  1631. X * Update a dialing directory entry.  Update only the one entry asked for,
  1632. X * not the entire image in memory.  If the new entry is beyond the end of
  1633. X * the physical file, then fill in the holes, and update "dir->d_entries".
  1634. X * A return code of 1 means a non-fatal error.
  1635. X */
  1636. X
  1637. Xint
  1638. Xupdate_dir(entry)
  1639. Xint entry;
  1640. X{
  1641. X    FILE *fp_in, *fp_out;
  1642. X    char *temp[NUM_DIR+1], buf[80], *strdup();
  1643. X    int i;
  1644. X    void error_win(), free_ptr();
  1645. X
  1646. X                    /* open for read */
  1647. X    if (!(fp_in = fopen(status->d_path, "r"))) {
  1648. X        sprintf(buf, "'%s' for read", status->d_path);
  1649. X        error_win(1, "Can't open dialing directory file", buf);
  1650. X    }
  1651. X                    /* read in a temporary version */
  1652. X    i = 0;
  1653. X    while (fgets(buf, 80, fp_in) != NULL)
  1654. X        temp[++i] = strdup(buf);
  1655. X    
  1656. X    fclose(fp_in);
  1657. X                    /* alter only 1 entry */
  1658. X    sprintf(buf, "DIR_%d=%s;%s;%d-%c-%d-%d;%c;%s\n", entry,
  1659. X     dir->name[entry], dir->number[entry], dir->baud[entry],
  1660. X     dir->parity[entry], dir->dbits[entry], dir->sbits[entry],
  1661. X     dir->duplex[entry], dir->index[entry]);
  1662. X
  1663. X    if (entry <= dir->d_entries)
  1664. X        free_ptr(temp[entry]);
  1665. X    temp[entry] = strdup(buf);
  1666. X                    /* fill in holes if beyond end */
  1667. X    if (entry > dir->d_entries+1) {
  1668. X        for (i=dir->d_entries+1; i<entry; i++) {
  1669. X            sprintf(buf, "DIR_%d=;;%d-%c-%d-%d;%c;\n", i,
  1670. X             param->d_baud, param->d_parity, param->d_dbits,
  1671. X             param->d_sbits, *param->d_duplex);
  1672. X            temp[i] = strdup(buf);
  1673. X        }
  1674. X    }
  1675. X                    /* update "dir->d_entries" */
  1676. X    if (entry > dir->d_entries)
  1677. X        dir->d_entries = entry;
  1678. X
  1679. X                    /* open for read */
  1680. X    if (!(fp_out = fopen(status->d_path, "w"))) {
  1681. X        for (i=1; i<=dir->d_entries; i++)
  1682. X            free_ptr(temp[i]);
  1683. X        sprintf(buf, "'%s'", status->d_path);
  1684. X        error_win(0, "No write permission on directory file", buf);
  1685. X        return(1);
  1686. X    }
  1687. X                    /* put it back */
  1688. X    for (i=1; i<=dir->d_entries; i++) {
  1689. X        fputs(temp[i], fp_out);
  1690. X        free_ptr(temp[i]);
  1691. X    }
  1692. X
  1693. X    fclose(fp_out);
  1694. X    return(0);
  1695. X}
  1696. X
  1697. X/*
  1698. X * Delete a range of dialing directory entries.  Actually, just copies
  1699. X * default (empty) entries in place of deleted entries.  However, it will
  1700. X * shrink the file if deletions occur at the physical EOF.  A return code
  1701. X * of 1 means a non-fatal error.
  1702. X */
  1703. X
  1704. Xint
  1705. Xdel_dir(first, last)
  1706. Xint first, last;
  1707. X{
  1708. X    FILE *fp_in, *fp_out;
  1709. X    int i;
  1710. X    char *temp[NUM_DIR+1], buf[80], *strdup();
  1711. X    void error_win(), free_ptr();
  1712. X                    /* sanity checking */
  1713. X    if (first > dir->d_entries)
  1714. X        return(0);
  1715. X    if (last > dir->d_entries)
  1716. X        last = dir->d_entries;
  1717. X
  1718. X                    /* open for read */
  1719. X    if (!(fp_in = fopen(status->d_path, "r"))) {
  1720. X        sprintf(buf, "'%s' for read", status->d_path);    
  1721. X        error_win(1, "Can't open dialing directory file", buf);
  1722. X    }
  1723. X                    /* read in a temporary version */
  1724. X    i = 0;
  1725. X    while (fgets(buf, 80, fp_in) != NULL)
  1726. X        temp[++i] = strdup(buf);
  1727. X
  1728. X    fclose(fp_in);
  1729. X                    /* delete the range of values */
  1730. X    for (i=first; i<=last; i++) {
  1731. X        sprintf(buf, "DIR_%d=;;%d-%c-%d-%d;%c;\n", i, param->d_baud,
  1732. X         param->d_parity, param->d_dbits, param->d_sbits,
  1733. X         *param->d_duplex);
  1734. X        free_ptr(temp[i]);
  1735. X        temp[i] = strdup(buf);
  1736. X    }
  1737. X                    /* shrink the file? */
  1738. X    if (last >= dir->d_entries) {
  1739. X        for (i=first; i<=last; i++)
  1740. X            free_ptr(temp[i]);
  1741. X        dir->d_entries = first-1;
  1742. X    }
  1743. X                    /* open for write */
  1744. X    if (!(fp_out = fopen(status->d_path, "w"))) {
  1745. X        for (i=1; i<=dir->d_entries; i++)
  1746. X            free_ptr(temp[i]);
  1747. X        sprintf(buf, "'%s'", status->d_path);
  1748. X        error_win(0, "No write permission on dialing directory file", buf);
  1749. X        return(1);
  1750. X    }
  1751. X                    /* put it all back */
  1752. X    for (i=1; i<=dir->d_entries; i++) {
  1753. X        fputs(temp[i], fp_out);
  1754. X        free_ptr(temp[i]);
  1755. X    }
  1756. X
  1757. X    fclose(fp_out);
  1758. X    return(0);
  1759. X}
  1760. SHAR_EOF
  1761. if test 6469 -ne "`wc -c < 'd_lib.c'`"
  1762. then
  1763.     echo shar: "error transmitting 'd_lib.c'" '(should have been 6469 characters)'
  1764. fi
  1765. fi
  1766. echo shar: "extracting 'd_manual.c'" '(1757 characters)'
  1767. if test -f 'd_manual.c'
  1768. then
  1769.     echo shar: "will not over-write existing file 'd_manual.c'"
  1770. else
  1771. sed 's/^X//' << \SHAR_EOF > 'd_manual.c'
  1772. X/*
  1773. X * The manual dial option of the dialing directory.  A return code of
  1774. X * 1 means we're ready to dial.  Dialing directory entry 0 is reserved
  1775. X * for the manual dial option.  No sanity checking is done on the input.
  1776. X */
  1777. X
  1778. X#include <stdio.h>
  1779. X#include <curses.h>
  1780. X#include "dial_dir.h"
  1781. X
  1782. Xint
  1783. Xmanual()
  1784. X{
  1785. X    WINDOW *m_win, *newwin();
  1786. X    char *number, *strdup(), *get_str(), ld_code, *strchr();
  1787. X    void fix_xmc(), free_ptr();
  1788. X    extern int xmc;
  1789. X    
  1790. X    m_win = newwin(5, 50, 0, 20);
  1791. X
  1792. X    box(m_win, '|', '-');
  1793. X    mvwaddstr(m_win, 2, 3, "Phone Number: ");
  1794. X    wrefresh(m_win);
  1795. X                    /* get a phone number */
  1796. X    if ((number = get_str(m_win, 30, NULL, NULL)) == NULL) {
  1797. X        werase(m_win);
  1798. X        wrefresh(m_win);
  1799. X        delwin(m_win);
  1800. X        if (xmc > 0)
  1801. X            fix_xmc();
  1802. X        return(0);
  1803. X    }
  1804. X                    /* is first char an LD code ? */
  1805. X    ld_code = NULL;
  1806. X    if (strchr("+-@#", *number)) {
  1807. X        ld_code = *number;
  1808. X        number++;
  1809. X    }
  1810. X                    /* put it in the queue */
  1811. X    dir->q_ld[0] = ld_code;
  1812. X    dir->q_num[0] = 0;
  1813. X                    /* end of queue marker */
  1814. X    dir->q_num[1] = -1;
  1815. X    dir->d_cur = 0;
  1816. X                    /* build the entry zero */
  1817. X    free_ptr(dir->name[0]);
  1818. X    free_ptr(dir->number[0]);
  1819. X    dir->name[0] = strdup(number);
  1820. X    dir->number[0] = strdup(number);
  1821. X                    /* it overlaps dm_win, so erase it */
  1822. X    werase(m_win);
  1823. X    wrefresh(m_win);
  1824. X    delwin(m_win);
  1825. X    if (xmc > 0)
  1826. X        fix_xmc();
  1827. X    return(1);
  1828. X}
  1829. X
  1830. X/*
  1831. X * Clear the end of the physical screen where the magic cookie got shifted
  1832. X * Geez, I hate magic cookie terminals...  Wyse, are you listening?
  1833. X */
  1834. X
  1835. Xvoid
  1836. Xfix_xmc()
  1837. X{
  1838. X    WINDOW *cl_win, *newwin();
  1839. X
  1840. X    /*
  1841. X     * Since the cookie got shifted off the window, we have to
  1842. X     * create a new window to cover where the cookie ended up.
  1843. X     */
  1844. X    cl_win = newwin(1, 2, 4, 78);
  1845. X                    /* have to touch, otherwise nothing! */
  1846. X    touchwin(cl_win);
  1847. X    wrefresh(cl_win);
  1848. X    delwin(cl_win);
  1849. X    
  1850. X    return;
  1851. X}
  1852. SHAR_EOF
  1853. if test 1757 -ne "`wc -c < 'd_manual.c'`"
  1854. then
  1855.     echo shar: "error transmitting 'd_manual.c'" '(should have been 1757 characters)'
  1856. fi
  1857. fi
  1858. echo shar: "extracting 'd_menu.c'" '(6870 characters)'
  1859. if test -f 'd_menu.c'
  1860. then
  1861.     echo shar: "will not over-write existing file 'd_menu.c'"
  1862. else
  1863. sed 's/^X//' << \SHAR_EOF > 'd_menu.c'
  1864. X/*
  1865. X * Routines for the dialing directory menu.
  1866. X */
  1867. X
  1868. X#include <stdio.h>
  1869. X#include <curses.h>
  1870. X#include "dial_dir.h"
  1871. X#include "misc.h"
  1872. X#include "param.h"
  1873. X
  1874. X/*
  1875. X * Display the dialing directory and prompt for options.  A return code of
  1876. X * 1 means we're ready to dial.
  1877. X */
  1878. X
  1879. Xint
  1880. Xdial_menu()
  1881. X{
  1882. X    WINDOW *dm_win, *newwin();
  1883. X    char buf[5], ld_code;
  1884. X    int ans, start, current, needs_repair, count, x, y, i, ret_code;
  1885. X    void scroll_dir(), active_ld(), disp_ld(), print_dir();
  1886. X    extern int xmc;
  1887. X
  1888. X    dm_win = newwin(22, 78, 1, 1);
  1889. X    mvwattrstr(dm_win, 1, 20, A_BOLD, "D I A L I N G       D I R E C T O R Y");
  1890. X    waddstr(dm_win, "\n-----------------------------------------------------------------------------\n");
  1891. X    wattrstr(dm_win, A_STANDOUT, "           Name                   Number        Baud P D S Dpx  Index/tty    ");
  1892. X                    /* show the first 10 entries */
  1893. X    scroll_dir(dm_win, 1);
  1894. X
  1895. X    mvwaddstr(dm_win, 15, 4, "==>");
  1896. X    mvwattrch(dm_win, 15, 14, A_BOLD, 'R');
  1897. X    waddstr(dm_win, " Revise");
  1898. X    mvwattrch(dm_win, 15, 32, A_BOLD, 'M');
  1899. X    waddstr(dm_win, " Manual Dialing");
  1900. X    mvwaddstr(dm_win, 15, 55, "Entry to Dial");
  1901. X
  1902. X    mvwattrch(dm_win, 16, 14, A_BOLD, 'P');
  1903. X    waddstr(dm_win, " LD Codes");
  1904. X    mvwattrch(dm_win, 16, 32, A_BOLD, 'D');
  1905. X    waddstr(dm_win, " Delete Entry");
  1906. X    mvwattrstr(dm_win, 16, 55, A_BOLD, "<cr>");
  1907. X    waddstr(dm_win, " Scroll Down");
  1908. X
  1909. X    mvwattrstr(dm_win, 17, 14, A_BOLD, "up/dn");
  1910. X    waddstr(dm_win, " Page");
  1911. X    mvwattrch(dm_win, 17, 32, A_BOLD, 'L');
  1912. X    waddstr(dm_win, " Print Entries");
  1913. X    mvwattrstr(dm_win, 17, 55, A_BOLD, "ESC");
  1914. X    waddstr(dm_win, " Exit");
  1915. X
  1916. X    mvwaddstr(dm_win, 19, 4, "LD Codes Active:");
  1917. X                    /* show which LD codes are active */
  1918. X    active_ld(dm_win);
  1919. X
  1920. X    box(dm_win, '|', '-');
  1921. X    y = 15;
  1922. X    x = 8;
  1923. X    wmove(dm_win, 15, 8);
  1924. X    wrefresh(dm_win);
  1925. X#ifndef OLDCURSES
  1926. X    keypad(dm_win, 1);
  1927. X#endif /* OLDCURSES */
  1928. X                    /* prompt for options */
  1929. X    current = 1;
  1930. X    count = 0;
  1931. X    ld_code = NULL;
  1932. X    ret_code = 0;
  1933. X    do {
  1934. X        needs_repair = 0;
  1935. X        ans = wgetch(dm_win);
  1936. X                    /* get an entry number */
  1937. X        if (ans >= '0' && ans <= '9') {
  1938. X            if (count > 2) {
  1939. X                beep();
  1940. X                continue;
  1941. X            }
  1942. X            buf[count] = ans;
  1943. X            waddch(dm_win, ans);
  1944. X            wrefresh(dm_win);
  1945. X            count++;
  1946. X            continue;
  1947. X        }
  1948. X        switch (ans) {
  1949. X            case 8:        /* do our own backspace */
  1950. X                if (!count) {
  1951. X                    beep();
  1952. X                    break;
  1953. X                }
  1954. X                count--;
  1955. X                if (!count)
  1956. X                    ld_code = NULL;
  1957. X                buf[count] = NULL;
  1958. X                getyx(dm_win, y, x);
  1959. X                x--;
  1960. X                wmove(dm_win, y, x);
  1961. X                waddch(dm_win, ' ');
  1962. X                wmove(dm_win, y, x);
  1963. X                wrefresh(dm_win);
  1964. X                break;
  1965. X#ifndef OLDCURSES
  1966. X            case KEY_UP:
  1967. X#endif /* OLDCURSES */
  1968. X            case 'u':
  1969. X            case 'U':    /* up arrow key */
  1970. X                if (current == 1) {
  1971. X                    beep();
  1972. X                    break;
  1973. X                }
  1974. X                start = current - 10;
  1975. X                if (start < 1)
  1976. X                    start = 1;
  1977. X                current = start;
  1978. X                scroll_dir(dm_win, start);
  1979. X                break;
  1980. X#ifndef OLDCURSES
  1981. X            case KEY_DOWN:
  1982. X            case '\n':
  1983. X#endif /* OLDCURSES */
  1984. X            case 'n':
  1985. X            case 'N':    /* down arrow key */
  1986. X                if (current == NUM_DIR-9) {
  1987. X                    beep();
  1988. X                    break;
  1989. X                }
  1990. X                start = current + 10;
  1991. X                if (start > NUM_DIR-9)
  1992. X                    start = NUM_DIR-9;
  1993. X                current = start;
  1994. X                scroll_dir(dm_win, start);
  1995. X                break;    
  1996. X            case '\r':    /* <CR> key */
  1997. X                if (!count) {
  1998. X                    if (current == NUM_DIR-9) {
  1999. X                        beep();
  2000. X                        break;
  2001. X                    }
  2002. X                    current++;
  2003. X                    if (current > NUM_DIR-9)
  2004. X                        current = NUM_DIR-9;
  2005. X                    scroll_dir(dm_win, current);
  2006. X                }
  2007. X                /*
  2008. X                 * The CR is used for the scroll-down-one-line
  2009. X                 * function, and to terminate numeric input.
  2010. X                 */
  2011. X                else {
  2012. X                    buf[count] = NULL;
  2013. X                    i = atoi(buf);
  2014. X                    if (!i || i > NUM_DIR) {
  2015. X                        beep();
  2016. X                        mvwaddstr(dm_win, 15, 8, "   ");
  2017. X                        x = 8;
  2018. X                        count = 0;
  2019. X                        break;
  2020. X                    }
  2021. X                    dir->q_ld[0] = ld_code;
  2022. X                    dir->q_num[0] = i;
  2023. X                    dir->d_cur = i;
  2024. X
  2025. X                    /* end of queue marker */
  2026. X                    dir->q_num[1] = -1;
  2027. X                    
  2028. X                    ret_code = 1;
  2029. X                    break;
  2030. X                }
  2031. X                break;    
  2032. X            case 'r':
  2033. X            case 'R':    /* revise */
  2034. X                if (revise()) {
  2035. X                    active_ld(dm_win);
  2036. X                    scroll_dir(dm_win, current);
  2037. X                }
  2038. X                touchwin(dm_win);
  2039. X                break;
  2040. X            case 'p':    /* display LD codes */
  2041. X            case 'P':
  2042. X                disp_ld();
  2043. X                touchwin(dm_win);
  2044. X                needs_repair = 1;
  2045. X                break;
  2046. X            case 'd':
  2047. X            case 'D':    /* delete a range of entries */
  2048. X                if (delete())
  2049. X                    scroll_dir(dm_win, current);
  2050. X                touchwin(dm_win);
  2051. X                break;
  2052. X            case 'm':
  2053. X            case 'M':    /* manual dial */
  2054. X                if (manual()) {
  2055. X                    ret_code = 1;
  2056. X                    break;
  2057. X                }
  2058. X                touchwin(dm_win);
  2059. X                needs_repair = 1;
  2060. X                break;
  2061. X            case 'l':
  2062. X            case 'L':    /* print the entries */
  2063. X                print_dir();
  2064. X                touchwin(dm_win);
  2065. X                needs_repair = 1;
  2066. X                break;
  2067. X            case '+':    /* LD codes */
  2068. X            case '-':
  2069. X            case '@':
  2070. X            case '#':
  2071. X                waddch(dm_win, ans);
  2072. X                wrefresh(dm_win);
  2073. X                ld_code = ans;
  2074. X                continue;
  2075. X            case 27:    /* ESC key (exit) */
  2076. X                break;
  2077. X            default:
  2078. X                beep();
  2079. X        }
  2080. X        if (ret_code)
  2081. X            break;
  2082. X                    /* magic cookie terminal ? */
  2083. X        if (xmc > 0 && needs_repair) {
  2084. X            clear_line(dm_win, 1, 0, 0);
  2085. X            clear_line(dm_win, 3, 0, 0);
  2086. X            wrefresh(dm_win);
  2087. X            mvwattrstr(dm_win, 1, 20, A_BOLD, "D I A L I N G       D I R E C T O R Y");
  2088. X            mvwattrstr(dm_win, 3, 0, A_STANDOUT, "           Name                   Number        Baud P D S Dpx  Index/tty    ");
  2089. X            box(dm_win, '|', '-');
  2090. X        }
  2091. X        wmove(dm_win, y, x);
  2092. X        wrefresh(dm_win);
  2093. X    } while (ans != 27);
  2094. X
  2095. X    werase(dm_win);
  2096. X    wrefresh(dm_win);
  2097. X    delwin(dm_win);
  2098. X    return(ret_code);
  2099. X}
  2100. X
  2101. X/*
  2102. X * Scroll the dialing directory.  Actually, we're not doing a real scroll
  2103. X * function on the screen, we're just repainting 10 lines.
  2104. X */
  2105. X
  2106. Xvoid
  2107. Xscroll_dir(win, start)
  2108. XWINDOW *win;
  2109. Xint start;
  2110. X{
  2111. X    int i;
  2112. X
  2113. X    wmove(win, 4, 0);
  2114. X    for (i=start; i<start+10; i++)
  2115. X        wprintw(win,
  2116. X         "%4d- %-20.20s %18.18s  %5d-%c-%d-%d  %c  %-14.14s\n", i,
  2117. X         dir->name[i], dir->number[i], dir->baud[i], dir->parity[i],
  2118. X         dir->dbits[i], dir->sbits[i], dir->duplex[i], dir->index[i]);
  2119. X    box(win, '|', '-');
  2120. X    return;
  2121. X}
  2122. X
  2123. X/*
  2124. X * Display the Long Distance codes.  Press any key to continue.
  2125. X */
  2126. X
  2127. Xvoid
  2128. Xdisp_ld()
  2129. X{
  2130. X    WINDOW *ld_win, *newwin();
  2131. X
  2132. X    ld_win = newwin(12, 30, 0, 0);
  2133. X    mvwaddstr(ld_win, 1, 5, "Long Distance Codes\n");
  2134. X    waddstr(ld_win, "------------------------------");
  2135. X    mvwprintw(ld_win, 3, 2, "+ %-20.20s", param->ld_plus);
  2136. X    mvwprintw(ld_win, 5, 2, "- %-20.20s", param->ld_minus);
  2137. X    mvwprintw(ld_win, 7, 2, "@ %-20.20s", param->ld_at);
  2138. X    mvwprintw(ld_win, 9, 2, "# %-20.20s", param->ld_pound);
  2139. X    box(ld_win, '|', '-');
  2140. X
  2141. X    mvwaddstr(ld_win, 11, 8, " Press any key ");
  2142. X    wmove(ld_win, 11, 29);
  2143. X    wrefresh(ld_win);
  2144. X    wgetch(ld_win);
  2145. X                    /* it overlaps, so erase it */
  2146. X    werase(ld_win);
  2147. X    wrefresh(ld_win);
  2148. X    delwin(ld_win);
  2149. X    return;
  2150. X}
  2151. X
  2152. X/*
  2153. X * Display which of the Long Distance codes are active.
  2154. X */
  2155. X
  2156. Xvoid
  2157. Xactive_ld(win)
  2158. XWINDOW *win;
  2159. X{
  2160. X    mvwaddstr(win, 19, 21, "        ");
  2161. X    wmove(win, 19, 21);
  2162. X                    /* a NULL pointer means not active */
  2163. X    if (*param->ld_plus != NULL)
  2164. X        waddstr(win, "+ ");
  2165. X    if (*param->ld_minus != NULL)
  2166. X        waddstr(win, "- ");
  2167. X    if (*param->ld_at != NULL)
  2168. X        waddstr(win, "@ ");
  2169. X    if (*param->ld_pound != NULL)
  2170. X        waddstr(win, "# ");
  2171. X    return;
  2172. X}
  2173. SHAR_EOF
  2174. if test 6870 -ne "`wc -c < 'd_menu.c'`"
  2175. then
  2176.     echo shar: "error transmitting 'd_menu.c'" '(should have been 6870 characters)'
  2177. fi
  2178. fi
  2179. exit 0
  2180. #    End of shell archive
  2181.